package com.gaohe.hotal.service.impl;

import java.util.List;
import com.gaohe.common.utils.DateUtils;
import com.gaohe.hotal.domain.HotBrand;
import com.gaohe.hotal.domain.HotHotal;
import com.gaohe.hotal.service.IHotBrandService;
import com.gaohe.hotal.vo.HotHotalVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gaohe.hotal.mapper.HotHotalMapper;
import com.gaohe.hotal.service.IHotHotalService;

/**
 * 门店管理Service业务层处理
 *
 * @author zl
 * @date 2025-06-26
 */
@Service
public class HotHotalServiceImpl implements IHotHotalService
{
    @Autowired
    private HotHotalMapper hotHotalMapper;

    @Autowired
    private IHotBrandService brandService;
    /**
     * 查询门店管理
     *
     * @param hotalId 门店管理主键
     * @return 门店管理
     */
    @Override
    public HotHotal selectHotHotalByhotalId(Long hotalId)
    {
        return hotHotalMapper.selectHotHotalByhotalId(hotalId);
    }

    /**
     * 查询门店管理列表
     *
     * @param hotHotal 门店管理
     * @return 门店管理
     */
    @Override
    public List<HotHotal> selectHotHotalList(HotHotal hotHotal)
    {
        return hotHotalMapper.selectHotHotalList(hotHotal);
    }

    /**
     * 新增门店管理
     *
     * @param hotHotal 门店管理
     * @return 结果
     */
    @Override
    public int insertHotHotal(HotHotal hotHotal)
    {
        hotHotal.setCreateTime(DateUtils.getNowDate());
        return hotHotalMapper.insertHotHotal(hotHotal);
    }

    /**
     * 修改门店管理
     *
     * @param hotHotal 门店管理
     * @return 结果
     */
    @Override
    public int updateHotHotal(HotHotal hotHotal)
    {
        hotHotal.setUpdateTime(DateUtils.getNowDate());
        return hotHotalMapper.updateHotHotal(hotHotal);
    }

    /**
     * 批量删除门店管理
     *
     * @param hotalIds 需要删除的门店管理主键
     * @return 结果
     */
    @Override
    public int deleteHotHotalByhotalIds(Long[] hotalIds)
    {
        return hotHotalMapper.deleteHotHotalByhotalIds(hotalIds);
    }

    /**
     * 删除门店管理信息
     *
     * @param hotalId 门店管理主键
     * @return 结果
     */
    @Override
    public int deleteHotHotalByhotalId(Long hotalId)
    {
        return hotHotalMapper.deleteHotHotalByhotalId(hotalId);
    }
//----------------------------------------------------------------------------------

    /**
     * 查询门店管理信息
     * @param hotHotal
     * @return
     */
    @Override
    public List<HotHotalVo> selectHotHotalVoList(HotHotal hotHotal) {
        List<HotHotalVo> hothotalVos = hotHotalMapper.selectHotHotalVoList(hotHotal);
        return hothotalVos;
    }

    /**
     * 通过门店查询信息
     * @param hotalId
     * @return
     */
    @Override
    public HotHotalVo gethotalById(Long hotalId) {
        HotHotal hotHotal = hotHotalMapper.selectHotHotalByhotalId(hotalId);
        HotHotalVo hotHotalVo = new HotHotalVo();
        BeanUtils.copyProperties(hotHotal,hotHotalVo);

        //  设置品牌名
        if (hotHotal.getBrandId()!=null){
            HotBrand hotBrand = brandService.selectHotBrandByBrandId(hotHotal.getBrandId());
            if (hotBrand!=null){
                hotHotalVo.setBrandName(hotBrand.getBrandName());
            }
        }
        return hotHotalVo;
    }
}
